package own.stu.jobgib.playown.fsm.squirrel;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.squirrelframework.foundation.fsm.HistoryType;
import org.squirrelframework.foundation.fsm.annotation.State;
import org.squirrelframework.foundation.fsm.annotation.StateMachineParameters;
import org.squirrelframework.foundation.fsm.annotation.States;
import org.squirrelframework.foundation.fsm.impl.AbstractUntypedStateMachine;

import static own.stu.jobgib.playown.fsm.squirrel.QuickStartSample.OrderState.*;
import static own.stu.jobgib.playown.fsm.squirrel.QuickStartSample.OrderOperateEnum.*;

@States({
        @State(name = "PAYED"),
        @State(name = "DELIVERY", historyType = HistoryType.DEEP),
        @State(parent = "DELIVERY", name = "ACCEPT", initialState = true),
        @State(parent = "DELIVERY", name = "DELIVERYING"),
        @State(parent = "DELIVERY", name = "DELIVERID"),
        @State(name = "SIGNED")
})
@StateMachineParameters(
        stateType = QuickStartSample.OrderState.class,
        eventType = QuickStartSample.OrderChangedEnum.class,
        contextType = Object.class
)
public class QuickStartSample extends AbstractUntypedStateMachine {

    public enum OrderState {
        PAYED,
        DELIVERY,
        //        enum DeliveryState {
        ACCEPT,
        DELIVERYING,
        DELIVERID,
        //        },
        SIGNED
    }

    @Getter
    @AllArgsConstructor
    enum OrderChangedEnum {
        TO_DELIVERY(PAYED, DELIVERY, FIND_DELIVER),
        ACCEPT_ORDER(DELIVERY, ACCEPT, DELIVER_ACCEPT),
        TO_DELIVERYING(ACCEPT, DELIVERYING, ORDER_DELIVERYING),
//        ACCEPT_ORDER(DELIVERY, ACCEPT, DELIVER_ACCEPT),

        ;
        private OrderState fromState;
        private OrderState toState;
        private OrderOperateEnum operate;

    }

    @Getter
    @AllArgsConstructor
    enum OrderOperateEnum {
        FIND_DELIVER,
        DELIVER_ACCEPT,
        ORDER_DELIVERYING
    }
}




